package com.stone.framework.push.websocket;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Component;

import com.stone.framework.message.push.MessageReqBody;

@Component
public class WebSocketEndpoint {

    @Autowired
    private SimpMessagingTemplate template;

    public void send(MessageReqBody reqBody) {
        template.convertAndSendToUser(reqBody.getUsername(), "/topic/notice", reqBody);
    }

    public void sendAll(MessageReqBody reqBody) {
        template.convertAndSend("/topic/notice", reqBody);
    }

}
